home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15159 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: vixen.cso.uiuc.edu!usenet
  2. From: Dragos-Anton Manolescu <manolesc@uiuc.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: HELP: trouble throwing a simple exception
  5. Date: 03 Apr 1996 17:49:32 -0600
  6. Organization: University of Illinois at Urbana-Champaign
  7. Message-ID: <opybocswab.fsf@sweetbay.will.uiuc.edu>
  8. Reply-To: Dragos Manolescu <manolesc@uiuc.edu>
  9. NNTP-Posting-Host: sweetbay.will.uiuc.edu
  10. X-Newsreader: Gnus v5.1
  11.  
  12.  
  13. Hello,
  14.  
  15. I'm having problems throwing a simple exception. I did step-by-step
  16. execution with gdb and the throw statement executes, nothing happens,
  17. and then the statements following throw execute. Here's the relevant
  18. piece from my code that throws the exception:
  19.  
  20.   if ((nfd=open(this->szFn,O_RDONLY)) == -1) // open the file and keep the fd
  21.     {
  22.       cerr << "Throwing exception here" << endl;
  23.       throw Nofile();
  24.     }
  25.  
  26.  
  27. and here's the part from the main program:
  28.  
  29.   Movie *m = 0;
  30.   try {
  31.   m = new Movie(argv[1]);
  32.   }
  33.   catch (Movie::Nofile) {
  34.     cerr << "Can't open input file " << argv[1] << endl;
  35.     delete m;        // Ok on null pointers
  36.     delete Schedule;
  37.     exit(-1);
  38.   }
  39.  
  40. I use g++ 2.7.2 and CXXFLAGS is -fhandle-exceptions -I/opt/parallax/include\
  41.  -I/usr/include/X11R5 -ggdb -Wall
  42.  
  43. What am I doing wrong here?
  44.  
  45. Please reply by e-mail if possible. Thank you for your time!
  46. -- 
  47. dam                                    http://www.uiuc.edu/ph/www/manolesc
  48.